package controller;

import dao.Xu_inspectionDao;
import entity.Xu_inspection;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import service.Xu_inspectionService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/xu_inspection")
@Scope("prototype")
public class Xu_inspectionController {
    @Resource(name = "xu_inspectionService")
    private Xu_inspectionService xu_inspectionService;
    @Resource(name = "xu_inspectionDao")
    private Xu_inspectionDao xu_inspectionDao;
    @RequestMapping("/queryConditionPage")
    @ResponseBody
    public Map<String,Object> queryConditionPage(String xunId,String xiafaRen,int renWuType,String xunXianLuId,int pageNumber, int pageSize){

        Map<String,Object> map = new HashMap<String,Object>() ;
        Map<String,Object> map1 = new HashMap<String,Object>() ;
        System.out.println(1);
        int xfr = -1;
        System.out.println("2");
        if(xiafaRen != null && xiafaRen != ""){
            xfr = Integer.parseInt(xiafaRen);
        }
        int xlid =-1;
        if(xunXianLuId != null && xunXianLuId != ""){
            xlid = Integer.parseInt(xunXianLuId);
        }
        System.out.println("4");
        map1.put("xunId",xunId);
        map1.put("xiafaRen",xfr);
        map1.put("renWuType",renWuType);
        map1.put("xunXianLuId",xlid);
        System.out.println("5");
        int i = (pageNumber-1)*pageSize;
        map1.put("11",i);
        map1.put("22",pageSize);
       System.out.println(map1.get(xunXianLuId));
        System.out.println(map1.get(renWuType));
        System.out.println(map1.get(xfr));
        System.out.println(map1.get(xunId));
        System.out.println(map1.get(11));
        System.out.println(map1.get(22));
        map.put("total",xu_inspectionDao.getCount(map1)) ;
        map.put("rows",xu_inspectionDao.query(map1));
        return map ;
    }
}
